package com.brainhealth.web.controller.customer;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.brainhealth.common.annotation.Log;
import com.brainhealth.common.core.controller.BaseController;
import com.brainhealth.common.core.domain.AjaxResult;
import com.brainhealth.common.enums.BusinessType;
import com.brainhealth.customer.domain.ChatCategory;
import com.brainhealth.customer.service.IChatCategoryService;
import com.brainhealth.common.utils.poi.ExcelUtil;
import com.brainhealth.common.core.page.TableDataInfo;

/**
 * 青竹聊天类型Controller
 * 
 * @author wolong
 * @date 2023-05-18
 */
@RestController
@RequestMapping("/customer/chatCategory")
public class ChatCategoryController extends BaseController
{
    @Autowired
    private IChatCategoryService chatCategoryService;

    /**
     * 查询青竹聊天类型列表
     */
    @PreAuthorize("@ss.hasPermi('customer:chatCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChatCategory chatCategory)
    {
        startPage();
        List<ChatCategory> list = chatCategoryService.selectChatCategoryList(chatCategory);
        return getDataTable(list);
    }

    /**
     * 导出青竹聊天类型列表
     */
    @PreAuthorize("@ss.hasPermi('customer:chatCategory:export')")
    @Log(title = "青竹聊天类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChatCategory chatCategory)
    {
        List<ChatCategory> list = chatCategoryService.selectChatCategoryList(chatCategory);
        ExcelUtil<ChatCategory> util = new ExcelUtil<ChatCategory>(ChatCategory.class);
        util.exportExcel(response, list, "青竹聊天类型数据");
    }

    /**
     * 获取青竹聊天类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:chatCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(chatCategoryService.selectChatCategoryById(id));
    }

    /**
     * 新增青竹聊天类型
     */
    @PreAuthorize("@ss.hasPermi('customer:chatCategory:add')")
    @Log(title = "青竹聊天类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChatCategory chatCategory)
    {
        return toAjax(chatCategoryService.insertChatCategory(chatCategory));
    }

    /**
     * 修改青竹聊天类型
     */
    @PreAuthorize("@ss.hasPermi('customer:chatCategory:edit')")
    @Log(title = "青竹聊天类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChatCategory chatCategory)
    {
        return toAjax(chatCategoryService.updateChatCategory(chatCategory));
    }

    /**
     * 删除青竹聊天类型
     */
    @PreAuthorize("@ss.hasPermi('customer:chatCategory:remove')")
    @Log(title = "青竹聊天类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chatCategoryService.deleteChatCategoryByIds(ids));
    }
}
